{layout name="public/layout" /}
{include file='yxnavbar'}


<div class="main">
    {include file='../../plugin/lingze/template/web/common_nav'}
    <div class="panel panel-default" role="tabpanel">
        <div class="panel-heading">基本信息</div>
        <div class="panel-body">
            <form action="" method="post" class="form-horizontal" role="form" name="form2" id="form2">
                <input type="hidden" name="lc_id" value="{$item['lc_id']}"/>
                <input type="hidden" name="themeid" value="{$themeid}"/>

                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span style="color: red;">*</span>奖品名称</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control"  placeholder="" name="chest_name"  value="{$item['chest_name']}">
                        <span class="help-block">显示在中奖后的弹窗 示例：苹果12Pro 限8个字以内</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span style="color: red;">*</span>宝箱名称</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control"  placeholder="" name="box_name"  value="{$item['box_name']}">
                        <span class="help-block">示例：金宝箱</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span style="color: red;">*</span>第几关</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="number" class="form-control"  placeholder="" name="level_sort"  value="{$item['level_sort']}">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 col-xs-12 control-label"><span style="color: red;">*</span>操作类型</label>
                    <div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">
                        <label class="radio-inline">
                            <input name="type" value="share" {if $item['type']=='share' || !$item['type']} checked="checked"{/if} type="radio"> 分享好友或群聊
                        </label>
                        <label class="radio-inline">
                            <input name="type" value="friend_view" {if $item['type']=='friend_view'} checked="checked"{/if} type="radio"> 好友到访
                        </label>
                        <label class="radio-inline">
                            <input name="type" value="friend_order" {if $item['type']=='friend_order'} checked="checked"{/if} type="radio"> 好友下单
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span style="color: red;">*</span>操作次数</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="number" class="form-control"  placeholder="" name="type_num"  value="{$item['type_num']}">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span style="color: red;">*</span>奖品小图</label>
                    <div class="col-sm-8 col-xs-12">
                        {php echo view_form_field_image('small_img',$item['small_img']);}
                        <span class="help-block">图片尺寸：200*200像素</span>
                    </div>
                </div>

                <div class="form-group" id="sub_upload" >
                    <div class="col-sm-12">
                        <input name="submit" onclick="addOrEditItem()" id="btnConfirm" type="button" value="提交" class="btn btn-primary col-lg-2">
                    </div>
                </div>

            </form>
        </div>
    </div>
</div>


<script type="text/javascript">
    //新增\修改奖品 提交数据
    function addOrEditItem() {
        let postUrl = "{php echo createWebUrlPlugin('lingze.add',array('themeid'=>$themeid));}";
        let success_redirect = "{php echo createWebUrlPlugin('lingze',array('themeid'=>$themeid));}";
        let formData = $("#form2").serialize();
        $.ajax({
            url:postUrl,
            dataType:'json',
            method:'post',
            data:formData,
            success:function (e) {
                let status = e.status;
                let result = e.result;
                if (status!=1){
                    layer.msg(result.msg)
                }else{
                    layer.msg(result.msg);
                    window.location.href = success_redirect;
                }
            },
            fail:function (err) {
                console.log(err)
            }
        })
    }
</script>
